plugins {
    id 'com.android.application'
    id 'org.jetbrains.kotlin.android'
    id 'kotlin-kapt'
    id 'kotlin-parcelize'
}

android {
    namespace 'com.redditmessaging'
    compileSdk 33

    defaultConfig {
        applicationId "com.redditmessaging"
        minSdk 28
        targetSdk 33
        versionCode 1
        versionName "1.0"

        testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
        kapt {
            arguments {
                arg("room.schemaLocation", "$projectDir/schemas")
            }
        }
    }

    buildTypes.each {
        Properties properties = new Properties()
        properties.load(project.rootProject.file( "reddit.properties" ).newDataInputStream ())

        def url = properties.getProperty( "baseUrl" , "" )
        it.buildConfigField "String" , "BASE_URL" , url
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
        }
    }
    compileOptions {
        sourceCompatibility JavaVersion.VERSION_17
        targetCompatibility JavaVersion.VERSION_17
    }
    kotlinOptions {
        jvmTarget = '17'
    }
    buildFeatures {
        viewBinding true
        buildConfig true
    }
}

dependencies {

    implementation 'androidx.core:core-ktx:1.8.0'
    implementation 'androidx.appcompat:appcompat:1.6.1'
    implementation 'com.google.android.material:material:1.5.0'
    implementation 'androidx.constraintlayout:constraintlayout:2.1.4'
    testImplementation 'junit:junit:4.13.2'
    androidTestImplementation 'androidx.test.ext:junit:1.1.5'
    androidTestImplementation 'androidx.test.espresso:espresso-core:3.5.1'

    implementation "androidx.activity:activity-ktx:1.7.2"
    implementation 'androidx.lifecycle:lifecycle-runtime-ktx:2.6.2'

    // coroutines
    implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-android:1.6.4'

    // for loading images
    implementation "com.github.bumptech.glide:glide:4.14.2"

    // pull-to-refresh
    implementation "androidx.swiperefreshlayout:swiperefreshlayout:1.1.0"

    // paging library v3
    implementation "androidx.paging:paging-runtime-ktx:3.2.1"

    //Koin
    implementation "io.insert-koin:koin-android:3.4.0"
    implementation "io.insert-koin:koin-core:3.4.0"
    implementation "io.insert-koin:koin-android-compat:3.4.0"


    //Retrofit
    implementation "com.squareup.retrofit2:retrofit:2.9.0"
    implementation "com.squareup.retrofit2:converter-gson:2.9.0"
    implementation "com.jakewharton.retrofit:retrofit2-kotlin-coroutines-adapter:0.9.2"
    implementation "com.squareup.okhttp3:logging-interceptor:4.9.2"

//Room
    def room_version = "2.5.2"
    implementation "androidx.room:room-runtime:$room_version"
    annotationProcessor "androidx.room:room-compiler:$room_version"
    kapt "androidx.room:room-compiler:$room_version"
    implementation "androidx.room:room-ktx:$room_version"
}